﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;
public partial class Menu_Menu_Show : System.Web.UI.Page
{
    public TongUse TextData = new TongUse();
    public string MenuListText;
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {

            MenuListText = ShowTree(0);//显示网站菜单
        }
            
        

    }




    

    /// <summary>
    /// SelectXML 方法要输出的XML文本文件
    /// </summary>
    string TreeXmlText = "";
    int ii = 0;
    /// <summary>
    /// 返回菜单显示的HTML代码
    /// </summary>
    /// <param name="select">显示的展次</param>
    /// <returns></returns>
    public String ShowTree(int select)
    {
        string sql;
        int i = 0;
        DataTable MyDt = new DataTable();
        sql = "Select * From TreeClass where followid=" + select + " order by id desc";
        try
        {
            
             MyDt = TextData.SqlataSet(sql).Tables[0];//创建DataTable MyDt
        }
        catch(Exception ex)
        {
            TextData.Err(ex.Message);
            
        }
        for (i = 0; i < MyDt.Rows.Count; i++)//遁环记录集
        {
            if (select == 0)//如果只一有层的话
            {

                TreeXmlText += "<tr>\r  <td width='223' class='tdbg' style='height: 27px'>\r" +

                     "  <a href='Menu_AddNew.aspx?action=Add&id=" + MyDt.Rows[i]["id"].ToString() + "' class='link1'>建立类别</a> |\r" +

                      "     <a href='Menu_Edit.aspx?action=Edit&id=" + MyDt.Rows[i]["id"].ToString() + "' class='link1'>编辑类别</a> | \r" +

                       "    <a href='Menu_del.aspx?id=" + MyDt.Rows[i]["id"].ToString() + "' class='link1'>删除类别</a> \r" +
                      " </td>\r"+ 
                  " <td width='787' class='tdbg' style='height: 27px'>\r"+

                     MyDt.Rows[i]["ClassName"].ToString() +
                  " </td>\r"+ 
                "</tr>\r";
            }
            else
            {
                TreeXmlText += "<tr>\r  <td width='223' class='tdbg' style='height: 27px'>\r" +

                                            "  <a href='Menu_AddNew.aspx?action=Add&id=" + MyDt.Rows[i]["id"].ToString() + "' class='link1'>建立类别</a> |\r" +

                      "     <a href='Menu_Edit.aspx?action=Edit&id=" + MyDt.Rows[i]["id"].ToString() + "' class='link1'>编辑类别</a> | \r" +

                       "    <a href='Menu_del.aspx?id=" + MyDt.Rows[i]["id"].ToString() + "' class='link1'>删除类别</a> \r" +
                        " </td>\r" +
                    " <td width='787' class='tdbg' style='height: 27px'>\r" +

                     TextData.EStr(ii, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") + MyDt.Rows[i]["ClassName"].ToString() +
                   " </td>\r"+
                "</tr>\r";
            }
            ii = ii + 1;
            ShowTree(int.Parse(MyDt.Rows[i]["id"].ToString()));//调用自己显示菜单ＨＴＭＬ
            ii -= 1;
            
        }

        return TreeXmlText;
    }


}
